'''
[1,2,3]
全排列
'''
import copy
class Solution:
    def permute(self, nums):
        res = []
        midres = []
        def dfs(p):
            if len(midres)==len(nums):
                kk = copy.deepcopy(midres)
                res.append(kk)
                return
            for i in p:
                midres.append(i)
                substr = p[:p.index(i)]+p[p.index(i)+1:]
                dfs(substr)
                midres.pop()
        dfs(nums)
        return res
if __name__ == '__main__':
    s = Solution()
    nums = [0,1]
    print(s.permute(nums))